package com.tang.framework.core.thread;

import jodd.util.ThreadFactoryBuilder;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@SpringBootConfiguration
public class CoolThreadPoolConfig {


    @Bean
    public ThreadPoolExecutor coolThreadCool() {
        return new ThreadPoolExecutor(3, 3,
                5L, TimeUnit.MINUTES,
                new LinkedBlockingDeque<>(),
                ThreadFactoryBuilder.create()
                        .withDaemon(true)
                        .withNameFormat("cool-thread:%s")
                        .get()
        );

    }
}
